*************************************************************************************************
* Documentation for Reproduction of
* Safe, Legal, Rare� and Early: Gender and the Politics of Abortion. 2011
* Journal of Elections, Public Opinion and Parties, 21(1): 83-96.
* L.J Zigerell
* Stata version 9
*************************************************************************************************
*************************************************************************************************
set more off
set mem 500m
* use "Zigerell Barker 2011 Safe Legal Rare and Early.dta", clear [This is the command to load the dataset]
*************************************************************************************************
*************************************************************************************************

* create control variables

tab gender
tab gender, nol mi
gen female = gender - 1
tab female, nol mi
tab female, nol

tab race
tab race, nol mi
gen black = race
recode black (1 3/8 = 0) (2=1)
tab black, nol mi
tab black, nol

gen hispanic = race
recode hispanic (1 2 4/8 = 0) (3=1)
tab hispanic, nol mi
tab hispanic, nol

tab marstat
tab marstat, nol mi
gen married = marstat
recode married (2/6=0)
tab married, nol mi
tab married, nol

summ birthyr
summ birthyr if birthyr == .
gen age = 2006 - birthyr
sum age

tab income
tab income, nol mi
clonevar hhincome = income
recode hhincome (15=.)
tab hhincome, nol mi
sum hhincome

tab educ
tab educ, nol mi
clonevar education = educ
tab education, nol mi
sum education

tab pr_churchatt
tab pr_churchatt, nol mi
clonevar relserv = pr_churchatt
tab relserv, nol mi
sum relserv

tab pr_randabort, gen(abt)
tab abt1, nol mi
tab abt2, nol mi
tab abt3, nol mi
tab abt4, nol mi
tab abt5, nol mi

*************************************************************************************************
* create conditions dependent variable 

tab abortopinion
tab abortopinion, nol mi
gen abcond4 = abortopinion

* recode conditions item based on volunteered responses (see supplemental document)

recode abcond4 (5=4) if caseid == 443378
recode abcond4 (5=.) if caseid == 443640
recode abcond4 (5=.) if caseid == 445622
recode abcond4 (5=.) if caseid == 448472
recode abcond4 (5=.) if caseid == 449385
recode abcond4 (5=4) if caseid == 454924
recode abcond4 (5=4) if caseid == 455451
recode abcond4 (5=.) if caseid == 522318
recode abcond4 (5=2) if caseid == 588820
recode abcond4 (5=.) if caseid == 592818
recode abcond4 (5=4) if caseid == 655756
recode abcond4 (5=.) if caseid == 710170
recode abcond4 (5=.) if caseid == 804294
recode abcond4 (5=2) if caseid == 836875
recode abcond4 (5=4) if caseid == 859599
recode abcond4 (5=4) if caseid == 892990
recode abcond4 (5=2) if caseid == 901077
recode abcond4 (5=.) if caseid == 903877
recode abcond4 (5=4) if caseid == 919346
recode abcond4 (5=2) if caseid == 923099
recode abcond4 (5=.) if caseid == 929554
recode abcond4 (5=2) if caseid == 959759
recode abcond4 (5=2) if caseid == 962510
recode abcond4 (5=2) if caseid == 967174
recode abcond4 (5=4) if caseid == 969588
recode abcond4 (5=4) if caseid == 970350
recode abcond4 (5=2) if caseid == 971366
recode abcond4 (5=.) if caseid == 975796
recode abcond4 (5=4) if caseid == 986784
recode abcond4 (5=.) if caseid == 990103
recode abcond4 (5=.) if caseid == 996295
recode abcond4 (5=4) if caseid == 996731
recode abcond4 (5=4) if caseid == 998138
recode abcond4 (5=2) if caseid == 1002185
recode abcond4 (5=.) if caseid == 1004797
recode abcond4 (5=4) if caseid == 1017477
recode abcond4 (5=.) if caseid == 1019010
recode abcond4 (5=2) if caseid == 1020210
recode abcond4 (5=.) if caseid == 1043577
recode abcond4 (5=4) if caseid == 1049135
recode abcond4 (5=2) if caseid == 1051017
recode abcond4 (5=2) if caseid == 1070653
recode abcond4 (5=.) if caseid == 1071784
recode abcond4 (5=.) if caseid == 1073159
recode abcond4 (5=2) if caseid == 1082960
recode abcond4 (5=2) if caseid == 1086293
recode abcond4 (5=.) if caseid == 1086772
recode abcond4 (5=.) if caseid == 1087616
recode abcond4 (5=4) if caseid == 1100444
recode abcond4 (5=.) if caseid == 1116668
recode abcond4 (5=4) if caseid == 1118325
recode abcond4 (5=.) if caseid == 1118974
recode abcond4 (5=.) if caseid == 1127036
recode abcond4 (5=.) if caseid == 1145450
recode abcond4 (5=.) if caseid == 1147340
recode abcond4 (5=4) if caseid == 1156280
recode abcond4 (5=.) if caseid == 1189565
recode abcond4 (5=4) if caseid == 1191902
recode abcond4 (5=.) if caseid == 1201284
recode abcond4 (5=2) if caseid == 1211959

tab abcond4

*************************************************************************************************
* create timing dependent variables

tab pr_aborttiming
tab pr_aborttiming, nol mi

gen abtime4 = pr_aborttiming
recode abtime4 (4=1) (3=2) (2=3) (1=4)
tab abtime4

*************************************************************************************************
* tab timing item for volunteered responses (for the supplemental document)

tab pr_aborttiming if caseid == 443378
tab pr_aborttiming if caseid == 443640
tab pr_aborttiming if caseid == 445622
tab pr_aborttiming if caseid == 448472
tab pr_aborttiming if caseid == 449385
tab pr_aborttiming if caseid == 454924
tab pr_aborttiming if caseid == 455451
tab pr_aborttiming if caseid == 522318
tab pr_aborttiming if caseid == 588820
tab pr_aborttiming if caseid == 592818
tab pr_aborttiming if caseid == 655756
tab pr_aborttiming if caseid == 710170
tab pr_aborttiming if caseid == 804294
tab pr_aborttiming if caseid == 836875
tab pr_aborttiming if caseid == 859599
tab pr_aborttiming if caseid == 892990
tab pr_aborttiming if caseid == 901077
tab pr_aborttiming if caseid == 903877
tab pr_aborttiming if caseid == 919346
tab pr_aborttiming if caseid == 923099
tab pr_aborttiming if caseid == 929554
tab pr_aborttiming if caseid == 959759
tab pr_aborttiming if caseid == 962510
tab pr_aborttiming if caseid == 967174
tab pr_aborttiming if caseid == 969588
tab pr_aborttiming if caseid == 970350
tab pr_aborttiming if caseid == 971366
tab pr_aborttiming if caseid == 975796
tab pr_aborttiming if caseid == 986784
tab pr_aborttiming if caseid == 990103
tab pr_aborttiming if caseid == 996295
tab pr_aborttiming if caseid == 996731
tab pr_aborttiming if caseid == 998138
tab pr_aborttiming if caseid == 1002185
tab pr_aborttiming if caseid == 1004797
tab pr_aborttiming if caseid == 1017477
tab pr_aborttiming if caseid == 1019010
tab pr_aborttiming if caseid == 1020210
tab pr_aborttiming if caseid == 1043577
tab pr_aborttiming if caseid == 1049135
tab pr_aborttiming if caseid == 1051017
tab pr_aborttiming if caseid == 1070653
tab pr_aborttiming if caseid == 1071784
tab pr_aborttiming if caseid == 1073159
tab pr_aborttiming if caseid == 1082960
tab pr_aborttiming if caseid == 1086293
tab pr_aborttiming if caseid == 1086772
tab pr_aborttiming if caseid == 1087616
tab pr_aborttiming if caseid == 1100444
tab pr_aborttiming if caseid == 1116668
tab pr_aborttiming if caseid == 1118325
tab pr_aborttiming if caseid == 1118974
tab pr_aborttiming if caseid == 1127036
tab pr_aborttiming if caseid == 1145450
tab pr_aborttiming if caseid == 1147340
tab pr_aborttiming if caseid == 1156280
tab pr_aborttiming if caseid == 1189565
tab pr_aborttiming if caseid == 1191902
tab pr_aborttiming if caseid == 1201284
tab pr_aborttiming if caseid == 1211959

*************************************************************************************************
* create elective but early dependent variable 

gen erle = .

// abcond4 == 1 is never permitted
// anyone selecting this is coded 0
recode erle (.=0) if abcond4 == 1 & abtime4 == 1
recode erle (.=0) if abcond4 == 1 & abtime4 == 2
recode erle (.=0) if abcond4 == 1 & abtime4 == 3
recode erle (.=0) if abcond4 == 1 & abtime4 == 4
recode erle (.=0) if abcond4 == 1 & abtime4 == .

// abcond4 == 2 is only permitted for rape incest or life
// anyone selecting this is coded 0
recode erle (.=0) if abcond4 == 2 & abtime4 == 1
recode erle (.=0) if abcond4 == 2 & abtime4 == 2
recode erle (.=0) if abcond4 == 2 & abtime4 == 3
recode erle (.=0) if abcond4 == 2 & abtime4 == 4
recode erle (.=0) if abcond4 == 2 & abtime4 == .

// abcond4 == 3 is only permitted with a need
// anyone selecting this is coded 0
recode erle (.=0) if abcond4 == 3 & abtime4 == 1
recode erle (.=0) if abcond4 == 3 & abtime4 == 2
recode erle (.=0) if abcond4 == 3 & abtime4 == 3
recode erle (.=0) if abcond4 == 3 & abtime4 == 4
recode erle (.=0) if abcond4 == 3 & abtime4 == .

// abcond4 == 4 is always legal

// those selecting abtime4 == 1 (before the first month) are coded 1
recode erle (.=1) if abcond4 == 4 & abtime4 == 1

// those selecting abtime4 == 2 (before the third month) are coded 1
recode erle (.=1) if abcond4 == 4 & abtime4 == 2

// those selecting abtime4 == 3 (before the sixth month) are coded 0
recode erle (.=0) if abcond4 == 4 & abtime4 == 3

// those selecting abtime4 == 4 (at any time) are coded 0
recode erle (.=0) if abcond4 == 4 & abtime4 == 4

// those not selecting an abtime4 are not coded
recode erle (.=.) if abcond4 == 4 & abtime4 == .

// recode respondents to the conditions item 
recode erle (.= 1) if caseid == 443378
recode erle (.= 1) if caseid == 443640
recode erle (.= 1) if caseid == 445622
recode erle (.= 1) if caseid == 448472
recode erle (.= 0) if caseid == 449385
recode erle (.= 0) if caseid == 454924
recode erle (.= 1) if caseid == 455451
recode erle (.= 0) if caseid == 522318
recode erle (.= 0) if caseid == 588820
recode erle (.= .) if caseid == 592818
recode erle (.= 1) if caseid == 655756
recode erle (.= 1) if caseid == 710170
recode erle (.= 1) if caseid == 804294
recode erle (.= 0) if caseid == 836875
recode erle (.= 1) if caseid == 859599
recode erle (.= 0) if caseid == 892990
recode erle (.= 0) if caseid == 901077
recode erle (.= .) if caseid == 903877
recode erle (.= 1) if caseid == 919346
recode erle (.= 0) if caseid == 923099
recode erle (.= 1) if caseid == 929554
recode erle (.= 0) if caseid == 959759
recode erle (.= 0) if caseid == 962510
recode erle (.= 0) if caseid == 967174
recode erle (.= 0) if caseid == 969588
recode erle (.= 0) if caseid == 970350
recode erle (.= 0) if caseid == 971366
recode erle (.= 1) if caseid == 975796
recode erle (.= 0) if caseid == 986784
recode erle (.= 0) if caseid == 990103
recode erle (.= 1) if caseid == 996295
recode erle (.= 1) if caseid == 996731
recode erle (.= 1) if caseid == 998138
recode erle (.= 0) if caseid == 1002185
recode erle (.= 0) if caseid == 1004797
recode erle (.= 0) if caseid == 1017477
recode erle (.= .) if caseid == 1019010
recode erle (.= 0) if caseid == 1020210
recode erle (.= .) if caseid == 1043577
recode erle (.= 0) if caseid == 1049135
recode erle (.= 0) if caseid == 1051017
recode erle (.= 0) if caseid == 1070653
recode erle (.= 1) if caseid == 1071784
recode erle (.= .) if caseid == 1073159
recode erle (.= 0) if caseid == 1082960
recode erle (.= 0) if caseid == 1086293
recode erle (.= .) if caseid == 1086772
recode erle (.= 1) if caseid == 1087616
recode erle (.= 1) if caseid == 1100444
recode erle (.= .) if caseid == 1116668
recode erle (.= 1) if caseid == 1118325
recode erle (.= .) if caseid == 1118974
recode erle (.= 1) if caseid == 1127036
recode erle (.= 0) if caseid == 1145450
recode erle (.= .) if caseid == 1147340
recode erle (.= .) if caseid == 1156280
recode erle (.= 0) if caseid == 1189565
recode erle (.= .) if caseid == 1191902
recode erle (.= 0) if caseid == 1201284
recode erle (.= 0) if caseid == 1211959

*************************************************************************************************
* tests

tab erle if abcond4 == 1
tab erle if abcond4 == 2
tab erle if abcond4 == 3
tab erle if abcond4 == 4

tab erle if abtime4 == 1
tab erle if abtime4 == 2
tab erle if abtime4 == 3
tab erle if abtime4 == 4

* absolute
gen absolute = erle
recode absolute (1=0)

recode absolute (0=1) if abcond4 == 1
recode absolute (0=1) if abcond4 == 4 & abtime4 == 4
tab absolute
tab absolute erle, nol mi

* absolute 2
gen abs = .

* never permitted
recode abs (.=1) if abcond4 == 1

* always permtited any time
recode abs (.=1) if abcond4 == 4 & abtime == 4

* others
recode abs (.=0) if abcond4 == 2
recode abs (.=0) if abcond4 == 3
recode abs (.=0) if abcond4 == 4 & abtime == 1
recode abs (.=0) if abcond4 == 4 & abtime == 2
recode abs (.=0) if abcond4 == 4 & abtime == 3

* other options
recode abs (.=0) if caseid == 443378
recode abs (.=0) if caseid == 443640
recode abs (.=0) if caseid == 445622
recode abs (.=0) if caseid == 448472
recode abs (.=1) if caseid == 449385
recode abs (.=0) if caseid == 454924
recode abs (.=0) if caseid == 455451
recode abs (.=0) if caseid == 522318
recode abs (.=0) if caseid == 588820
recode abs (.=.) if caseid == 592818
recode abs (.=0) if caseid == 655756
recode abs (.=0) if caseid == 710170
recode abs (.=0) if caseid == 804294
recode abs (.=0) if caseid == 836875
recode abs (.=0) if caseid == 859599
recode abs (.=0) if caseid == 892990
recode abs (.=0) if caseid == 901077
recode abs (.=.) if caseid == 903877
recode abs (.=0) if caseid == 919346
recode abs (.=0) if caseid == 923099
recode abs (.=0) if caseid == 929554
recode abs (.=0) if caseid == 959759
recode abs (.=0) if caseid == 962510
recode abs (.=0) if caseid == 967174
recode abs (.=0) if caseid == 969588
recode abs (.=1) if caseid == 970350
recode abs (.=0) if caseid == 971366
recode abs (.=0) if caseid == 975796
recode abs (.=1) if caseid == 986784
recode abs (.=0) if caseid == 990103
recode abs (.=0) if caseid == 996295
recode abs (.=0) if caseid == 996731
recode abs (.=0) if caseid == 998138
recode abs (.=0) if caseid == 1002185
recode abs (.=.) if caseid == 1004797
recode abs (.=1) if caseid == 1017477
recode abs (.=.) if caseid == 1019010
recode abs (.=0) if caseid == 1020210
recode abs (.=.) if caseid == 1043577
recode abs (.=1) if caseid == 1049135
recode abs (.=0) if caseid == 1051017
recode abs (.=0) if caseid == 1070653
recode abs (.=0) if caseid == 1071784
recode abs (.=.) if caseid == 1073159
recode abs (.=0) if caseid == 1082960
recode abs (.=0) if caseid == 1086293
recode abs (.=0) if caseid == 1086772
recode abs (.=0) if caseid == 1087616
recode abs (.=0) if caseid == 1100444
recode abs (.=.) if caseid == 1116668
recode abs (.=0) if caseid == 1118325
recode abs (.=.) if caseid == 1118974
recode abs (.=0) if caseid == 1127036
recode abs (.=0) if caseid == 1145450
recode abs (.=0) if caseid == 1147340
recode abs (.=.) if caseid == 1156280
recode abs (.=0) if caseid == 1189565
recode abs (.=.) if caseid == 1191902
recode abs (.=0) if caseid == 1201284
recode abs (.=0) if caseid == 1211959

*************************************************************************************************
* table 1

tab1 abcond4 abtime4 erle
tab1 abcond4 abtime4 erle, nol mi

tab1 abcond4 abtime4 erle if female == 1
tab1 abcond4 abtime4 erle if female == 1, nol mi

tab1 abcond4 abtime4 erle if female == 0
tab1 abcond4 abtime4 erle if female == 0, nol mi

tab female abcond4, chi2
tab female abtime4, chi2
tab female erle, chi2

*************************************************************************************************
* table 2

ologit abcond4 female black hispanic married age hhincome education relserv abt1 abt2 abt3 abt4, cluster(district)
brant

mlogit abcond4 female black hispanic married age hhincome education relserv abt1 abt2 abt3 abt4, cluster(district) base(2)
fitstat
estsimp mlogit abcond4 female black hispanic married age hhincome education relserv abt1 abt2 abt3 abt4, cluster(district) base(2)
setx mean
setx female 0
simqi
setx female 1
simqi
drop b1-b39

*************************************************************************************************
* table 3

ologit abtime4 female black hispanic married age hhincome education relserv abt1 abt2 abt3 abt4, cluster(district)
brant
mlogit abtime4 female black hispanic married age hhincome education relserv abt1 abt2 abt3 abt4, cluster(district) base(2)
fitstat
estsimp mlogit abtime4 female black hispanic married age hhincome education relserv abt1 abt2 abt3 abt4, cluster(district) base(2)
setx mean
setx female 0
simqi
setx female 1
simqi
drop b1-b39

*************************************************************************************************
* table 4

logit erle female black hispanic married age hhincome education relserv abt1 abt2 abt3 abt4, cluster(district)
estat gof, group(10)
prchange female, fromto help
estsimp probit erle female black hispanic married age hhincome education relserv abt1 abt2 abt3 abt4, cluster(district) /* this should have been a logit regression */
setx mean
setx female 0
simqi
setx female 1
simqi
drop b1-b13

*************************************************************************************************
* footnote 5

tab pr_aborttiming if abortopinion == 1, mi

gen abtime5i = abtime4
tab abtime5i
replace abtime5i = 0 if abortopinion == 1
mlogit abtime5i female black hispanic married age hhincome education relserv abt1 abt2 abt3 abt4, cluster(district) base(2)
mlogit abtime4 female black hispanic married age hhincome education relserv abt1 abt2 abt3 abt4, cluster(district) base(2)

*************************************************************************************************
* for the referees

pwcorr abcond4 abtime4 erle, sig obs

tab votereg 
tab votereg, nol mi
recode votereg (2=0) (3=.)

tab vote06turn
tab vote06turn, nol mi
recode vote06turn (4=3)

tab pt_natlnewswatchweek
tab pt_natlnewswatchweek, nol mi

tab pid3 erle
tab postq7 erle

logit erle female black hispanic married age hhincome education relserv abt1 abt2 abt3 abt4 votereg vote06turn pt_natlnewswatchweek, cluster(district)
estat gof, group(10)
estsimp logit erle female black hispanic married age hhincome education relserv abt1 abt2 abt3 abt4 votereg vote06turn pt_natlnewswatchweek, cluster(district)
setx mean
setx mean
setx female 0
simqi
setx female 1
simqi
drop b1-b16
*************************************************************************************************
*************************************************************************************************
